<template>
	<view>
		<cu-custom :isBack="true" bgColor="bg-blue">
			<block slot="content">板坯库存</block>
			<template slot="backText">
				<text class="cuIcon-back" @tap="beforePage"></text>
			</template>
		</cu-custom>
		<!-- 主题内容 -->
		<view  class="padding-t">
			<view class="public-main-info">
				<view class="u-main">
					<view class="u-main-info padding2030">
						<!-- 板坯搜索 -->
						<!-- <view v-show="false" class="padding-b">
							<view class="search">
								<input class="search-input font-size24" focus placeholder="板坯号查询" />
								<text class="cuIcon-search text-blue search-icon"></text>
							</view>
						</view> -->
						<!-- 下面表格 -->
						<view class="u-table">
							<view>
								<view class="u-table-head">
									<view class="u-table-head-item u-font-weight" v-for="(item, index) in tableHeads" :key="index">{{item.name}}</view>
								</view>
								<view>
									<!-- class="u-table-bady" -->
									<scroll-view scroll-y="true" :style="{height: uHeight + 'px'}">
										<view class="u-table-bady-column" v-for="(item, indexs) in tableData" :key="indexs">
											<view class="u-table-head-item">{{item.steelType}}</view>
											<view class="u-table-head-item">{{item.specification}}</view>
											<view class="u-table-head-item">{{item.weight}}</view>
											<view class="u-table-head-item">{{item.num}}</view>
										</view>
										<view class="loading-info" v-show="flag">
											{{info}}
										</view>
									</scroll-view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { post } from "@/lib/Util.js";
	import {GET_SLAB_INFO} from '@/common/api/yuanliao.js'
	export default {
		data() {
			return {
				flag: false,
				info: '正在加载中……',
				pageIndex: 1,
				pageSize: 50,
				tableHeads: [
					{
						name: '钢种',
					},
					{
						name: '规格',
					},
					{
						name: '重量(t)',
					},
					{
						name: '板坯数量',
					}
				],
				tableData: [],
				uHeight: 0
			}
		},
		mounted() {
			this.getInfo()
			var len = 0
			uni.getSystemInfo({
				success: function (res) {
					console.log(res.windowHeight)
					len = res.windowHeight
				}
			})
			this.uHeight = len - this.CustomBar - 40 - 54 - 40
		},
		methods: {
			beforePage() {
				uni.navigateBack({
					delta: 1
				});
			},
			async getInfo() {
				let res = await post(GET_SLAB_INFO)
				this.tableData = res.data
				// if(res.code == 0) {
				// 	if(res.data.length <= 0) {
				// 		this.flag = false
				// 		this.info = '到底啦'
				// 	}else {
				// 		this.tableData = this.tableData.concat(res.data)
				// 	}
				// }else {
				// 	this.flag = false
				// }
			},
			lower(e) {
				if (e.target.direction == "bottom") {
					this.flag = true
					this.info = '加载中……'
					++this.pageIndex
					this.getInfo()
				}
			}
		}
	}
</script>

<style>
</style>
